import request from '@/utils/request';
import { url } from '@/api/url';

// 看板中心-获取看板列表
export async function getPanels(): Promise<any> {
  return request(url.queryPanelsList);
}

// 看板中心-获取指标列表
export async function getDashboard(params: any) {
  return request(url.queryDashboardsUrl(params));
}

// 看板中心-获取指标图表数据所需参数
export async function getWidgetParams(params: any) {
  return request(url.queryWidgetParamsUrl(params));
}

// 看板中心-获取指标图表数据
export async function getWidgetData(params: any) {
  return request(url.queryWidgetDataUrl(params), {
    method: 'POST',
    data: params.body,
  });
}

// 订阅指标
export async function subscribeWidget(params: any) {
  return request(url.subscribeWidgetUrl, {
    method: 'POST',
    data: params,
  });
}

// 取消订阅指标
export async function canelSubscribeWidget(params: any) {
  return request(url.canelSubscribeWidgetUrl, {
    method: 'POST',
    data: params,
  });
}

// 获取我的订阅列表
export async function getSubscribeWidgets() {
  return request(url.querySubscribeWidgetsUrl);
}

// 保存订阅列表排版
export async function savePosition(params: any) {
  return request(url.savePositionUrl, {
    method: 'POST',
    data: params,
  });
}

// 获取所有指标列表
export async function getDashboards() {
  return request(url.queryWidgetsUrl);
}

// 存储感兴趣的指标
export async function saveWidgetRecord(params: any) {
  return request(url.saveWidgetRecordUrl, {
    method: 'POST',
    data: params,
  });
}

// 获取感兴趣的指标
export async function getWidgetRecords() {
  return request(url.queryWidgetRecordsUrl);
}

// 获取所有指标筛选条件
export async function getLevels() {
  return request(url.queryLevelsUrl);
}
